package wechat

import (
	"github.com/ArtisanCloud/PowerWeChat/v3/src/miniProgram"
	"social-app/config"
)

var (
	MiniProgramApp      *miniProgram.MiniProgram
	MiniProgramAppError error
)

func init() {
	MiniProgramApp, MiniProgramAppError = miniProgram.NewMiniProgram(&miniProgram.UserConfig{
		AppID:     config.WeChatConfig.Appid,  // 小程序appid
		Secret:    config.WeChatConfig.Secret, // 小程序app secret
		HttpDebug: config.WeChatConfig.HttpDebug,
		Log: miniProgram.Log{
			Level: config.WeChatConfig.Log.Level,
			// 可以重定向到你的目录下，如果设置File和Error，默认会在当前目录下的wechat文件夹下生成日志
			File:   config.WeChatConfig.Log.File,
			Error:  config.WeChatConfig.Log.Error,
			Stdout: config.WeChatConfig.Log.Stdout, //  是否打印在终端
		},
		// 可选，不传默认走程序内存
		//Cache: kernel.NewRedisClient(&kernel.UniversalOptions{
		//	Addrs:     []string{"127.0.0.1:6379"},
		//	Password: "",
		//	DB:       0,
		//}),
	})
}
